define(function(require, exports, module) {
    "use strict";
    var $ = require("$"),
        app = require("dist/application/app"),
        config = app.config,
        method = app.method;
    require("sparkline")
    var charts = require("dist/charts/init.js");
    var $visit = $("#visit_charts"),
        $turnover = $(".js_turnover"),
        $refund = $(".js_refund");
    $visit.length && (function(e) {
        var path = $visit.data("path");
        path && method.get(path, function(d) {
            charts.line("visit_charts", d)
        })

    })(); 
    $turnover.length && (function() {
        var path = $turnover.data("path");
        path && method.get(path, function(d) { 
            $turnover.sparkline(d.list, {
                fillColor: "",
                height: 100,
                highlightLineColor: "#fff",
                lineColor: "#dddddd",
                lineWidth: 2,
                resize: true,
                spotColor: "#bbbbbb",
                spotRadius: 3,
                type: "line",
                width: "100%",
                tooltipOffsetX:-80,
                tooltipFormatter:function(ev){
                    var region = ev.getCurrentRegionFields(),
                    value = region.y,
                    index=region.x;
                    return '<span>'+d.date[index]+'<br/><span>'+d.name+'：'+value+'</span></span>'
                }
            });
            
        })
    })();
    $refund.length && (function() {
        var path = $refund.data("path"); 
        path && method.get(path, function(d) { 
            $refund.sparkline(d.list, {
                type: "bar",
                height: 50,
                barWidth: 6,
                barSpacing: 10,
                barColor: "#65bd77",
                tooltipFormatter:function(ev){
                    var region = ev.getCurrentRegionFields(),
                    value = region[0].value,
                    index=region[0].offset;
                    return '<span>'+d.date[index]+'<br/><span>'+d.name+'：'+value+'</span></span>'
                }
            })
        })
    })();


})
